mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	SwRasterizer/Lighting: pass lighting state as parameter
This commit is contained in:
		
							parent
							
								
									f3660ba9dd
								
							
						
					
					
						commit
						efc655aec0
					
				
					 1 changed files with 13 additions and 13 deletions
				
			
		|  | @ -116,7 +116,7 @@ static std::tuple<float24, float24, PAddr> ConvertCubeCoord(float24 u, float24 v | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static float LookupLightingLut(const Pica::State::Lighting& lighting, size_t lut_index, u8 index, | static float LookupLightingLut(const Pica::State::Lighting& lighting, size_t lut_index, u8 index, | ||||||
|                         float delta) { |                                float delta) { | ||||||
|     ASSERT_MSG(lut_index < lighting.luts.size(), "Out of range lut"); |     ASSERT_MSG(lut_index < lighting.luts.size(), "Out of range lut"); | ||||||
|     ASSERT_MSG(index < lighting.luts[0].size(), "Out of range index"); |     ASSERT_MSG(index < lighting.luts[0].size(), "Out of range index"); | ||||||
| 
 | 
 | ||||||
|  | @ -129,8 +129,8 @@ static float LookupLightingLut(const Pica::State::Lighting& lighting, size_t lut | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( | std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( | ||||||
|     const Pica::LightingRegs& lighting, const Math::Quaternion<float>& normquat, |     const Pica::LightingRegs& lighting, const Pica::State::Lighting& lighting_state, | ||||||
|     const Math::Vec3<float>& view) { |     const Math::Quaternion<float>& normquat, const Math::Vec3<float>& view) { | ||||||
| 
 | 
 | ||||||
|     // TODO(Subv): Bump mapping
 |     // TODO(Subv): Bump mapping
 | ||||||
|     Math::Vec3<float> surface_normal = {0.0f, 0.0f, 1.0f}; |     Math::Vec3<float> surface_normal = {0.0f, 0.0f, 1.0f}; | ||||||
|  | @ -148,7 +148,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( | ||||||
| 
 | 
 | ||||||
|     for (unsigned light_index = 0; light_index <= lighting.max_light_index; ++light_index) { |     for (unsigned light_index = 0; light_index <= lighting.max_light_index; ++light_index) { | ||||||
|         unsigned num = lighting.light_enable.GetNum(light_index); |         unsigned num = lighting.light_enable.GetNum(light_index); | ||||||
|         const auto& light_config = g_state.regs.lighting.light[num]; |         const auto& light_config = lighting.light[num]; | ||||||
| 
 | 
 | ||||||
|         Math::Vec3<float> refl_value = {}; |         Math::Vec3<float> refl_value = {}; | ||||||
|         Math::Vec3<float> position = {float16::FromRaw(light_config.x).ToFloat32(), |         Math::Vec3<float> position = {float16::FromRaw(light_config.x).ToFloat32(), | ||||||
|  | @ -176,7 +176,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( | ||||||
|             u8 lutindex = |             u8 lutindex = | ||||||
|                 static_cast<u8>(MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f)); |                 static_cast<u8>(MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f)); | ||||||
|             float delta = sample_loc * 256 - lutindex; |             float delta = sample_loc * 256 - lutindex; | ||||||
|             dist_atten = LookupLightingLut(g_state.lighting, lut, lutindex, delta); |             dist_atten = LookupLightingLut(lighting_state, lut, lutindex, delta); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         auto GetLutIndex = [&](unsigned num, LightingRegs::LightingLutInput input, |         auto GetLutIndex = [&](unsigned num, LightingRegs::LightingLutInput input, | ||||||
|  | @ -243,7 +243,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( | ||||||
| 
 | 
 | ||||||
|             d0_lut_value = |             d0_lut_value = | ||||||
|                 scale * |                 scale * | ||||||
|                 LookupLightingLut(g_state.lighting, |                 LookupLightingLut(lighting_state, | ||||||
|                                   static_cast<size_t>(LightingRegs::LightingSampler::Distribution0), |                                   static_cast<size_t>(LightingRegs::LightingSampler::Distribution0), | ||||||
|                                   index, delta); |                                   index, delta); | ||||||
|         } |         } | ||||||
|  | @ -264,7 +264,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( | ||||||
| 
 | 
 | ||||||
|             refl_value.x = |             refl_value.x = | ||||||
|                 scale * |                 scale * | ||||||
|                 LookupLightingLut(g_state.lighting, |                 LookupLightingLut(lighting_state, | ||||||
|                                   static_cast<size_t>(LightingRegs::LightingSampler::ReflectRed), |                                   static_cast<size_t>(LightingRegs::LightingSampler::ReflectRed), | ||||||
|                                   index, delta); |                                   index, delta); | ||||||
|         } else { |         } else { | ||||||
|  | @ -285,7 +285,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( | ||||||
| 
 | 
 | ||||||
|             refl_value.y = |             refl_value.y = | ||||||
|                 scale * |                 scale * | ||||||
|                 LookupLightingLut(g_state.lighting, |                 LookupLightingLut(lighting_state, | ||||||
|                                   static_cast<size_t>(LightingRegs::LightingSampler::ReflectGreen), |                                   static_cast<size_t>(LightingRegs::LightingSampler::ReflectGreen), | ||||||
|                                   index, delta); |                                   index, delta); | ||||||
|         } else { |         } else { | ||||||
|  | @ -306,7 +306,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( | ||||||
| 
 | 
 | ||||||
|             refl_value.z = |             refl_value.z = | ||||||
|                 scale * |                 scale * | ||||||
|                 LookupLightingLut(g_state.lighting, |                 LookupLightingLut(lighting_state, | ||||||
|                                   static_cast<size_t>(LightingRegs::LightingSampler::ReflectBlue), |                                   static_cast<size_t>(LightingRegs::LightingSampler::ReflectBlue), | ||||||
|                                   index, delta); |                                   index, delta); | ||||||
|         } else { |         } else { | ||||||
|  | @ -328,7 +328,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( | ||||||
| 
 | 
 | ||||||
|             d1_lut_value = |             d1_lut_value = | ||||||
|                 scale * |                 scale * | ||||||
|                 LookupLightingLut(g_state.lighting, |                 LookupLightingLut(lighting_state, | ||||||
|                                   static_cast<size_t>(LightingRegs::LightingSampler::Distribution1), |                                   static_cast<size_t>(LightingRegs::LightingSampler::Distribution1), | ||||||
|                                   index, delta); |                                   index, delta); | ||||||
|         } |         } | ||||||
|  | @ -350,7 +350,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( | ||||||
| 
 | 
 | ||||||
|             float lut_value = |             float lut_value = | ||||||
|                 scale * |                 scale * | ||||||
|                 LookupLightingLut(g_state.lighting, |                 LookupLightingLut(lighting_state, | ||||||
|                                   static_cast<size_t>(LightingRegs::LightingSampler::Fresnel), |                                   static_cast<size_t>(LightingRegs::LightingSampler::Fresnel), | ||||||
|                                   index, delta); |                                   index, delta); | ||||||
| 
 | 
 | ||||||
|  | @ -729,8 +729,8 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve | ||||||
|             Math::Vec4<u8> secondary_fragment_color = {0, 0, 0, 0}; |             Math::Vec4<u8> secondary_fragment_color = {0, 0, 0, 0}; | ||||||
| 
 | 
 | ||||||
|             if (!g_state.regs.lighting.disable) { |             if (!g_state.regs.lighting.disable) { | ||||||
|                 std::tie(primary_fragment_color, secondary_fragment_color) = |                 std::tie(primary_fragment_color, secondary_fragment_color) = ComputeFragmentsColors( | ||||||
|                     ComputeFragmentsColors(g_state.regs.lighting, normquat, fragment_position); |                     g_state.regs.lighting, g_state.lighting, normquat, fragment_position); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             for (unsigned tev_stage_index = 0; tev_stage_index < tev_stages.size(); |             for (unsigned tev_stage_index = 0; tev_stage_index < tev_stages.size(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue