diff --git a/src/video_core/regs_lighting.h b/src/video_core/regs_lighting.h index 8ef1d21364..3c5499a9f0 100644 --- a/src/video_core/regs_lighting.h +++ b/src/video_core/regs_lighting.h @@ -59,16 +59,6 @@ struct LightingRegs { ///< NOTE: '8' is intentional, '7' does not appear to be a valid configuration }; - /// Selects which lighting components are affected by fresnel - enum class LightingFresnelSelector : u32 { - None = 0, ///< Fresnel is disabled - PrimaryAlpha = 1, ///< Primary (diffuse) lighting alpha is affected by fresnel - SecondaryAlpha = 2, ///< Secondary (specular) lighting alpha is affected by fresnel - Both = - PrimaryAlpha | - SecondaryAlpha, ///< Both primary and secondary lighting alphas are affected by fresnel - }; - /// Factor used to scale the output of a lighting LUT enum class LightingScale : u32 { Scale1 = 0, ///< Scale is 1x @@ -188,7 +178,8 @@ struct LightingRegs { union { BitField<0, 1, u32> enable_shadow; - BitField<2, 2, LightingFresnelSelector> fresnel_selector; + BitField<2, 1, u32> enable_primary_alpha; + BitField<3, 1, u32> enable_secondary_alpha; BitField<4, 4, LightingConfig> config; BitField<16, 1, u32> shadow_primary; BitField<17, 1, u32> shadow_secondary; diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index af5be62d7a..8e0964496d 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -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"; } } diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h index 7d14d2c710..12bda326f9 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.h +++ b/src/video_core/renderer_opengl/gl_shader_gen.h @@ -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; diff --git a/src/video_core/swrasterizer/lighting.cpp b/src/video_core/swrasterizer/lighting.cpp index fb345e0774..130e1b5d56 100644 --- a/src/video_core/swrasterizer/lighting.cpp +++ b/src/video_core/swrasterizer/lighting.cpp @@ -251,16 +251,12 @@ std::tuple, Math::Vec4> ComputeFragmentsColors( lighting.lut_scale.fr, LightingRegs::LightingSampler::Fresnel); // Enabled for diffuse lighting alpha component - if (lighting.config0.fresnel_selector == - LightingRegs::LightingFresnelSelector::PrimaryAlpha || - lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { + if (lighting.config0.enable_primary_alpha) { diffuse_sum.a() = lut_value; } // Enabled for the specular lighting alpha component - if (lighting.config0.fresnel_selector == - LightingRegs::LightingFresnelSelector::SecondaryAlpha || - lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { + if (lighting.config0.enable_secondary_alpha) { specular_sum.a() = lut_value; } } @@ -308,16 +304,12 @@ std::tuple, Math::Vec4> ComputeFragmentsColors( if (lighting.config0.shadow_alpha) { // Alpha shadow also uses the Fresnel selecotr to determine which alpha to apply // Enabled for diffuse lighting alpha component - if (lighting.config0.fresnel_selector == - LightingRegs::LightingFresnelSelector::PrimaryAlpha || - lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { + if (lighting.config0.enable_primary_alpha) { diffuse_sum.a() *= shadow.w; } // Enabled for the specular lighting alpha component - if (lighting.config0.fresnel_selector == - LightingRegs::LightingFresnelSelector::SecondaryAlpha || - lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { + if (lighting.config0.enable_secondary_alpha) { specular_sum.a() *= shadow.w; } }