Compare commits
	
		
			6 Commits
		
	
	
		
			1b13d92b99
			...
			42daa8a048
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 42daa8a048 | |
|  | 196f739afd | |
|  | bf602a6964 | |
|  | 2cc5ab44b7 | |
|  | b8a5169b78 | |
|  | a5571c9f76 | 
|  | @ -37,9 +37,9 @@ public class LmParams : IChunk | ||||||
|     public DepthMode ShadowDepth { get; set; } |     public DepthMode ShadowDepth { get; set; } | ||||||
|     public bool LightmappedWater { get; set; } |     public bool LightmappedWater { get; set; } | ||||||
|     public int LightmapScale { get; set; } |     public int LightmapScale { get; set; } | ||||||
|  |     public uint AnimLightCutoff { get; set; } | ||||||
|      |      | ||||||
|     private int _dataSize; |     private int _dataSize; | ||||||
|     private uint _unknown; |  | ||||||
|      |      | ||||||
|     public void ReadData(BinaryReader reader, DbFile.TableOfContents.Entry entry) |     public void ReadData(BinaryReader reader, DbFile.TableOfContents.Entry entry) | ||||||
|     { |     { | ||||||
|  | @ -53,7 +53,7 @@ public class LmParams : IChunk | ||||||
|         LightmappedWater = reader.ReadBoolean(); |         LightmappedWater = reader.ReadBoolean(); | ||||||
|         reader.ReadBytes(3); |         reader.ReadBytes(3); | ||||||
|         LightmapScale = reader.ReadInt32(); |         LightmapScale = reader.ReadInt32(); | ||||||
|         _unknown = reader.ReadUInt32(); |         AnimLightCutoff = reader.ReadUInt32(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void WriteData(BinaryWriter writer) |     public void WriteData(BinaryWriter writer) | ||||||
|  | @ -68,6 +68,6 @@ public class LmParams : IChunk | ||||||
|         writer.Write(LightmappedWater); |         writer.Write(LightmappedWater); | ||||||
|         writer.Write(new byte[3]); |         writer.Write(new byte[3]); | ||||||
|         writer.Write(LightmapScale); |         writer.Write(LightmapScale); | ||||||
|         writer.Write(_unknown); |         writer.Write(AnimLightCutoff); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | @ -51,15 +51,11 @@ public class Light | ||||||
|         Matrix4x4 rotate, |         Matrix4x4 rotate, | ||||||
|         Matrix4x4 scale) |         Matrix4x4 scale) | ||||||
|     { |     { | ||||||
|         var transform = scale * rotate * translate; |         Position = Vector3.Transform(Position, rotate) + Vector3.Transform(vhotLightPos, scale * rotate * translate); | ||||||
|         vhotLightPos = Vector3.Transform(vhotLightPos, transform); |         SpotlightDir = Vector3.Normalize(Vector3.Transform(vhotLightDir, scale * rotate)); | ||||||
|         vhotLightDir = Vector3.Transform(vhotLightDir, transform); |  | ||||||
|          |  | ||||||
|         Position = Vector3.Transform(Position, rotate) + vhotLightPos; |  | ||||||
|         SpotlightDir = Vector3.Normalize(vhotLightDir - vhotLightPos); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public float StrengthAtPoint(Vector3 point, Plane plane) |     public float StrengthAtPoint(Vector3 point, Plane plane, uint lightCutoff) | ||||||
|     { |     { | ||||||
|         // Calculate light strength at a given point. As far as I can tell |         // Calculate light strength at a given point. As far as I can tell | ||||||
|         // this is exact to Dark (I'm a genius??). It's just an inverse distance |         // this is exact to Dark (I'm a genius??). It's just an inverse distance | ||||||
|  | @ -76,6 +72,13 @@ public class Light | ||||||
|             strength *= (Radius - len) / (Radius - InnerRadius); |             strength *= (Radius - len) / (Radius - InnerRadius); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         // Anim lights have a (configurable) minimum light cutoff. This is checked before | ||||||
|  |         // spotlight multipliers are applied so we don't cutoff the spot radius falloff. | ||||||
|  |         if (Anim && strength * Brightness < lightCutoff) | ||||||
|  |         { | ||||||
|  |             return 0f; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         // This is basically the same as how inner radius works. It just applies |         // This is basically the same as how inner radius works. It just applies | ||||||
|         // a linear falloff to 0 between the inner angle and outer angle. |         // a linear falloff to 0 between the inner angle and outer angle. | ||||||
|         if (Spotlight) |         if (Spotlight) | ||||||
|  |  | ||||||
|  | @ -25,6 +25,7 @@ public class LightMapper | ||||||
|         public float MultiSamplingCenterWeight; |         public float MultiSamplingCenterWeight; | ||||||
|         public bool LightmappedWater; |         public bool LightmappedWater; | ||||||
|         public SunSettings Sunlight; |         public SunSettings Sunlight; | ||||||
|  |         public uint AnimLightCutoff; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private ResourcePathManager.CampaignResources _campaign; |     private ResourcePathManager.CampaignResources _campaign; | ||||||
|  | @ -85,6 +86,7 @@ public class LightMapper | ||||||
|             MultiSamplingCenterWeight = lmParams.CenterWeight, |             MultiSamplingCenterWeight = lmParams.CenterWeight, | ||||||
|             LightmappedWater = lmParams.LightmappedWater, |             LightmappedWater = lmParams.LightmappedWater, | ||||||
|             Sunlight = sunlightSettings, |             Sunlight = sunlightSettings, | ||||||
|  |             AnimLightCutoff = lmParams.AnimLightCutoff, | ||||||
|         }; |         }; | ||||||
|          |          | ||||||
|         Timing.TimeStage("Gather Lights", BuildLightList); |         Timing.TimeStage("Gather Lights", BuildLightList); | ||||||
|  | @ -258,7 +260,7 @@ public class LightMapper | ||||||
|                 } |                 } | ||||||
|                 if (model.TryGetVhot(ModelFile.VhotId.LightDirection, out vhot)) |                 if (model.TryGetVhot(ModelFile.VhotId.LightDirection, out vhot)) | ||||||
|                 { |                 { | ||||||
|                     vhotLightDir = vhot.Position - model.Header.Center; |                     vhotLightDir = (vhot.Position - model.Header.Center) - vhotLightPos; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | @ -272,7 +274,7 @@ public class LightMapper | ||||||
|             { |             { | ||||||
|                 Position = propAnimLight.Offset, |                 Position = propAnimLight.Offset, | ||||||
|                 Color = Utils.HsbToRgb(propLightColor.Hue, propLightColor.Saturation, propAnimLight.MaxBrightness), |                 Color = Utils.HsbToRgb(propLightColor.Hue, propLightColor.Saturation, propAnimLight.MaxBrightness), | ||||||
|                 Brightness = propAnimLight.Brightness, |                 Brightness = propAnimLight.MaxBrightness, | ||||||
|                 InnerRadius = propAnimLight.InnerRadius, |                 InnerRadius = propAnimLight.InnerRadius, | ||||||
|                 Radius = propAnimLight.Radius, |                 Radius = propAnimLight.Radius, | ||||||
|                 R2 = propAnimLight.Radius * propAnimLight.Radius, |                 R2 = propAnimLight.Radius * propAnimLight.Radius, | ||||||
|  | @ -317,6 +319,7 @@ public class LightMapper | ||||||
|                 { |                 { | ||||||
|                     Position = light.Position, |                     Position = light.Position, | ||||||
|                     Color = Utils.HsbToRgb(propLightColor.Hue, propLightColor.Saturation, propSpotAmb.SpotBrightness), |                     Color = Utils.HsbToRgb(propLightColor.Hue, propLightColor.Saturation, propSpotAmb.SpotBrightness), | ||||||
|  |                     Brightness = propSpotAmb.SpotBrightness, | ||||||
|                     InnerRadius = light.InnerRadius, |                     InnerRadius = light.InnerRadius, | ||||||
|                     Radius = light.Radius, |                     Radius = light.Radius, | ||||||
|                     R2 = light.R2, |                     R2 = light.R2, | ||||||
|  | @ -594,7 +597,7 @@ public class LightMapper | ||||||
|                                  |                                  | ||||||
|                                 if (TraceRay(light.Position, point)) |                                 if (TraceRay(light.Position, point)) | ||||||
|                                 { |                                 { | ||||||
|                                     strength += targetWeights[idx] * light.StrengthAtPoint(point, plane); |                                     strength += targetWeights[idx] * light.StrengthAtPoint(point, plane, settings.AnimLightCutoff); | ||||||
|                                 } |                                 } | ||||||
|                             } |                             } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue