Extract light strength calculation to method in prep for inner radius handling
This commit is contained in:
		
							parent
							
								
									dcecc33bcd
								
							
						
					
					
						commit
						dca1b1e5ed
					
				|  | @ -339,15 +339,7 @@ class Program | |||
|                             var hit = hitResult && Math.Abs(hitResult.Distance - direction.Length()) < MathUtils.Epsilon; | ||||
|                             if (hit) | ||||
|                             { | ||||
|                                 // 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 | ||||
|                                 // falloff with diffuse angle, except we have to scale the length. | ||||
|                                 var dir = light.position - pos; | ||||
|                                 var angle = Vector3.Dot(Vector3.Normalize(dir), plane.Normal); | ||||
|                                 var len = dir.Length(); | ||||
|                                 var slen = len / 4.0f; | ||||
|                                 var strength = (angle + 1.0f) / slen; | ||||
| 
 | ||||
|                                 var strength = CalculateLightStrengthAtPoint(light, pos, plane); | ||||
|                                 lightmap.AddLight(0, x, y, light.color, strength, hdr); | ||||
|                             } | ||||
|                         } | ||||
|  | @ -361,6 +353,20 @@ class Program | |||
|         Console.Write("\n"); | ||||
|     } | ||||
| 
 | ||||
|     private static float CalculateLightStrengthAtPoint(Light light, Vector3 point, Plane plane) | ||||
|     { | ||||
|         // 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 | ||||
|         // falloff with diffuse angle, except we have to scale the length. | ||||
|         var dir = light.position - point; | ||||
|         var angle = Vector3.Dot(Vector3.Normalize(dir), plane.Normal); | ||||
|         var len = dir.Length(); | ||||
|         var slen = len / 4.0f; | ||||
|         var strength = (angle + 1.0f) / slen; | ||||
| 
 | ||||
|         return strength; | ||||
|     } | ||||
| 
 | ||||
|     private static void ResetLightmap(Vector3 ambientLight, WorldRep.Cell.Lightmap lightmap, bool hdr) | ||||
|     { | ||||
|         for (var i = 0; i < lightmap.Pixels.Length; i++) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue