pica/lighting: split FresnelSelector into bitfields
The FresnelSelector was already working like a bitfield, so just make it actual bitfield to reduce redundant code. Also, it is already confirmed that this field also affects shadow on alpha. Given that the only two source that can affect alpha components are both controlled by this field, this field should be renamed to a general alpha switch
This commit is contained in:
@@ -154,7 +154,8 @@ PicaShaderConfig PicaShaderConfig::BuildFromRegs(const Pica::Regs& regs) {
|
||||
state.lighting.lut_rb.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.rb);
|
||||
|
||||
state.lighting.config = regs.lighting.config0.config;
|
||||
state.lighting.fresnel_selector = regs.lighting.config0.fresnel_selector;
|
||||
state.lighting.enable_primary_alpha = regs.lighting.config0.enable_primary_alpha;
|
||||
state.lighting.enable_secondary_alpha = regs.lighting.config0.enable_secondary_alpha;
|
||||
state.lighting.bump_mode = regs.lighting.config0.bump_mode;
|
||||
state.lighting.bump_selector = regs.lighting.config0.bump_selector;
|
||||
state.lighting.bump_renorm = regs.lighting.config0.disable_bump_renorm == 0;
|
||||
@@ -803,15 +804,12 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) {
|
||||
value = "(" + std::to_string(lighting.lut_fr.scale) + " * " + value + ")";
|
||||
|
||||
// Enabled for diffuse lighting alpha component
|
||||
if (lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::PrimaryAlpha ||
|
||||
lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) {
|
||||
if (lighting.enable_primary_alpha) {
|
||||
out += "diffuse_sum.a = " + value + ";\n";
|
||||
}
|
||||
|
||||
// Enabled for the specular lighting alpha component
|
||||
if (lighting.fresnel_selector ==
|
||||
LightingRegs::LightingFresnelSelector::SecondaryAlpha ||
|
||||
lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) {
|
||||
if (lighting.enable_secondary_alpha) {
|
||||
out += "specular_sum.a = " + value + ";\n";
|
||||
}
|
||||
}
|
||||
|
@@ -76,7 +76,8 @@ struct PicaShaderConfigState {
|
||||
bool clamp_highlights;
|
||||
|
||||
Pica::LightingRegs::LightingConfig config;
|
||||
Pica::LightingRegs::LightingFresnelSelector fresnel_selector;
|
||||
bool enable_primary_alpha;
|
||||
bool enable_secondary_alpha;
|
||||
|
||||
struct {
|
||||
bool enable;
|
||||
|
Reference in New Issue
Block a user