Light rendering optimization

This commit is contained in:
Regalis
2015-12-19 16:02:05 +02:00
parent 4234aa2094
commit e10bffde9b
6 changed files with 52 additions and 13 deletions
@@ -60,6 +60,10 @@ namespace Barotrauma.Lights
public void DrawLOS(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Vector2 pos)
{
Stopwatch sw = new Stopwatch();
sw.Start();
if (!LosEnabled) return;
Rectangle camView = new Rectangle(cam.WorldView.X, cam.WorldView.Y - cam.WorldView.Height, cam.WorldView.Width, cam.WorldView.Height);
@@ -75,6 +79,9 @@ namespace Barotrauma.Lights
convexHull.DrawShadows(graphics, cam, pos, shadowTransform);
}
sw.Stop();
Debug.WriteLine("drawlos: " + sw.ElapsedTicks + " (" + sw.ElapsedMilliseconds + ")");
if (!ObstructVision) return;
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative);
@@ -82,6 +89,7 @@ namespace Barotrauma.Lights
spriteBatch.End();
ObstructVision = false;
}
public void OnMapLoaded()
@@ -94,6 +102,10 @@ namespace Barotrauma.Lights
public void UpdateLightMap(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam)
{
Stopwatch sw = new Stopwatch();
sw.Start();
if (!LightingEnabled) return;
Matrix shadowTransform = cam.ShaderTransform
@@ -152,6 +164,10 @@ namespace Barotrauma.Lights
graphics.SetRenderTarget(null);
Debug.WriteLine("lights: " + sw.ElapsedTicks + " (" + sw.ElapsedMilliseconds + ")");
if (!ObstructVision) return;
}
public void UpdateObstructVision(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Vector2 lookAtPosition)