diff --git a/Subsurface/Content/Map/background.png b/Subsurface/Content/Map/background.png
index 3a0044f6b..923b03581 100644
Binary files a/Subsurface/Content/Map/background.png and b/Subsurface/Content/Map/background.png differ
diff --git a/Subsurface/Content/Map/background2.png b/Subsurface/Content/Map/background2.png
index 71a7675c7..9a5d8f8e3 100644
Binary files a/Subsurface/Content/Map/background2.png and b/Subsurface/Content/Map/background2.png differ
diff --git a/Subsurface/Source/Map/Levels/CaveGenerator.cs b/Subsurface/Source/Map/Levels/CaveGenerator.cs
index 539cb595c..542ba571c 100644
--- a/Subsurface/Source/Map/Levels/CaveGenerator.cs
+++ b/Subsurface/Source/Map/Levels/CaveGenerator.cs
@@ -348,9 +348,9 @@ namespace Barotrauma
return pathCells;
}
- public static List
GeneratePolygons(List cells, out List verticeList, bool setSolid=true)
+ public static List GeneratePolygons(List cells, out List verticeList, bool setSolid=true)
{
- verticeList = new List();
+ verticeList = new List();
var bodies = new List();
List tempVertices = new List();
@@ -388,7 +388,12 @@ namespace Barotrauma
{
foreach (Vector2 vertex in triangles[i])
{
- verticeList.Add(new VertexPositionColor(new Vector3(vertex, 0.0f), Color.Black));
+ //shift the coordinates around a bit to make the texture repetition less obvious
+ Vector2 uvCoords = new Vector2(
+ vertex.X / 2000.0f + (float)Math.Sin(vertex.X / 500.0f) * 0.15f,
+ vertex.Y / 2000.0f + (float)Math.Sin(vertex.Y / 700.0f) * 0.15f);
+
+ verticeList.Add(new VertexPositionTexture(new Vector3(vertex, 1.0f), uvCoords));
}
}
diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs
index 864872efc..70a45bc83 100644
--- a/Subsurface/Source/Map/Levels/Level.cs
+++ b/Subsurface/Source/Map/Levels/Level.cs
@@ -437,7 +437,7 @@ namespace Barotrauma
List cellsWithBody = new List(cells);
- List bodyVertices;
+ List bodyVertices;
bodies = CaveGenerator.GeneratePolygons(cellsWithBody, out bodyVertices);
renderer.SetBodyVertices(bodyVertices.ToArray());
diff --git a/Subsurface/Source/Map/Levels/LevelRenderer.cs b/Subsurface/Source/Map/Levels/LevelRenderer.cs
index 008dbdcc7..3c1cb824a 100644
--- a/Subsurface/Source/Map/Levels/LevelRenderer.cs
+++ b/Subsurface/Source/Map/Levels/LevelRenderer.cs
@@ -11,7 +11,7 @@ namespace Barotrauma
{
class LevelRenderer : IDisposable
{
- private static BasicEffect basicEffect;
+ private static BasicEffect wallEdgeEffect, wallCenterEffect;
private static Sprite background, backgroundTop;
private static Sprite dustParticles;
@@ -39,14 +39,29 @@ namespace Barotrauma
dustParticles = new Sprite("Content/Map/dustparticles.png", Vector2.Zero);
}
- if (basicEffect == null)
+ if (wallEdgeEffect == null)
{
- basicEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
- basicEffect.VertexColorEnabled = false;
-
- basicEffect.TextureEnabled = true;
- basicEffect.Texture = TextureLoader.FromFile("Content/Map/iceWall.png");
+ wallEdgeEffect = new BasicEffect(GameMain.CurrGraphicsDevice)
+ {
+ DiffuseColor = new Vector3(0.8f, 0.8f, 0.8f),
+ VertexColorEnabled = false,
+ TextureEnabled = true,
+ Texture = shaftTexture
+ };
+ wallEdgeEffect.CurrentTechnique = wallEdgeEffect.Techniques["BasicEffect_Texture"];
}
+
+ if (wallCenterEffect == null)
+ {
+ wallCenterEffect = new BasicEffect(GameMain.CurrGraphicsDevice)
+ {
+ VertexColorEnabled = false,
+ TextureEnabled = true,
+ Texture = backgroundTop.Texture
+ };
+ wallCenterEffect.CurrentTechnique = wallCenterEffect.Techniques["BasicEffect_Texture"];
+ }
+
if (backgroundSpriteManager==null)
{
@@ -79,9 +94,9 @@ namespace Barotrauma
wallVertices.SetData(vertices);
}
- public void SetBodyVertices(VertexPositionColor[] vertices)
+ public void SetBodyVertices(VertexPositionTexture[] vertices)
{
- bodyVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
+ bodyVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
bodyVertices.SetData(vertices);
}
@@ -96,21 +111,20 @@ namespace Barotrauma
if (backgroundPos.Y < 1024)
{
- if (backgroundPos.Y > -1024)
- {
- background.SourceRect = new Rectangle((int)backgroundPos.X, (int)Math.Max(backgroundPos.Y, 0), 1024, 1024);
- background.DrawTiled(spriteBatch,
- (backgroundPos.Y < 0) ? new Vector2(0.0f, -backgroundPos.Y) : Vector2.Zero,
- new Vector2(GameMain.GraphicsWidth, 1024 - backgroundPos.Y),
- Vector2.Zero, level.BackgroundColor);
- }
-
if (backgroundPos.Y < 0)
{
backgroundTop.SourceRect = new Rectangle((int)backgroundPos.X, (int)backgroundPos.Y, 1024, (int)Math.Min(-backgroundPos.Y, 1024));
backgroundTop.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(GameMain.GraphicsWidth, Math.Min(-backgroundPos.Y, GameMain.GraphicsHeight)),
Vector2.Zero, level.BackgroundColor);
}
+ if (backgroundPos.Y > -1024)
+ {
+ background.SourceRect = new Rectangle((int)backgroundPos.X, (int)Math.Max(backgroundPos.Y, 0), 1024, 1024);
+ background.DrawTiled(spriteBatch,
+ (backgroundPos.Y < 0) ? new Vector2(0.0f, (int)-backgroundPos.Y) : Vector2.Zero,
+ new Vector2(GameMain.GraphicsWidth, (int)Math.Ceiling(1024 - backgroundPos.Y)),
+ Vector2.Zero, level.BackgroundColor);
+ }
}
spriteBatch.End();
@@ -205,64 +219,21 @@ namespace Barotrauma
{
if (wallVertices == null) return;
- basicEffect.World = cam.ShaderTransform
- * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
+ wallEdgeEffect.World = cam.ShaderTransform
+ * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 100) * 0.5f;
+ wallCenterEffect.World = wallEdgeEffect.World;
+ //render the solid center of the wall cells
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
- graphicsDevice.BlendState = BlendState.AlphaBlend;
graphicsDevice.SetVertexBuffer(bodyVertices);
-
- basicEffect.VertexColorEnabled = true;
- basicEffect.TextureEnabled = false;
- basicEffect.CurrentTechnique = basicEffect.Techniques["BasicEffect_VertexColor"];
- basicEffect.CurrentTechnique.Passes[0].Apply();
+ wallCenterEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(bodyVertices.VertexCount / 3.0f));
-
- /*
- for (int side = 0; side < 2; side++)
- {
- for (int i = 0; i < 2; i++)
- {
- basicEffect.World = Matrix.CreateTranslation(new Vector3(level.WrappingWalls[side, i].Offset, 0.0f)) * cam.ShaderTransform
- * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
- basicEffect.CurrentTechnique.Passes[0].Apply();
-
-
- graphicsDevice.SetVertexBuffer(level.WrappingWalls[side, i].BodyVertices);
-
- graphicsDevice.DrawPrimitives(
- PrimitiveType.TriangleList, 0,
- (int)Math.Floor(level.WrappingWalls[side, i].BodyVertices.VertexCount / 3.0f));
- }
- }*/
-
-
- graphicsDevice.SetVertexBuffer(wallVertices);
- basicEffect.VertexColorEnabled = false;
- basicEffect.TextureEnabled = true;
- basicEffect.CurrentTechnique = basicEffect.Techniques["BasicEffect_Texture"];
- basicEffect.CurrentTechnique.Passes[0].Apply();
- graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wallVertices.VertexCount / 3.0f));
- /*
- for (int side = 0; side < 2; side++)
- {
- for (int i = 0; i < 2; i++)
- {
-
- basicEffect.World = Matrix.CreateTranslation(new Vector3(level.WrappingWalls[side,i].Offset, 0.0f)) * cam.ShaderTransform
- * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
- basicEffect.CurrentTechnique.Passes[0].Apply();
-
- graphicsDevice.SetVertexBuffer(level.WrappingWalls[side, i].WallVertices);
-
- graphicsDevice.DrawPrimitives(
- PrimitiveType.TriangleList, 0,
- (int)Math.Floor(level.WrappingWalls[side, i].WallVertices.VertexCount / 3.0f));
-
- }
- }*/
+ //render the edges of the wall cells
+ graphicsDevice.SetVertexBuffer(wallVertices);
+ wallEdgeEffect.CurrentTechnique.Passes[0].Apply();
+ graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wallVertices.VertexCount / 3.0f));
}
public void Dispose()