Merge pull request #220 from mrpimpunicorn/master
Merge lighting improvements
This commit is contained in:
commit
0cb618c3b4
@ -36,10 +36,6 @@ namespace TrueCraft.Client.Modules
|
||||
ChunkRenderer.Start();
|
||||
|
||||
OpaqueEffect = new BasicEffect(Game.GraphicsDevice);
|
||||
OpaqueEffect.EnableDefaultLighting();
|
||||
OpaqueEffect.DirectionalLight0.SpecularColor = Color.Black.ToVector3();
|
||||
OpaqueEffect.DirectionalLight1.SpecularColor = Color.Black.ToVector3();
|
||||
OpaqueEffect.DirectionalLight2.SpecularColor = Color.Black.ToVector3();
|
||||
OpaqueEffect.TextureEnabled = true;
|
||||
OpaqueEffect.Texture = Game.TextureMapper.GetTexture("terrain.png");
|
||||
OpaqueEffect.FogEnabled = true;
|
||||
|
@ -39,11 +39,11 @@ namespace TrueCraft.Client.Rendering
|
||||
};
|
||||
for (int i = 0; i < texture.Length; i++)
|
||||
texture[i] *= new Vector2(16f / 256f);
|
||||
return CreateUniformCube(offset, texture, faces, indiciesOffset, out indicies, Color.White);
|
||||
return CreateUniformCube(offset, texture, faces, indiciesOffset, out indicies, Color.White, descriptor.BlockLight);
|
||||
}
|
||||
|
||||
public static VertexPositionNormalColorTexture[] CreateUniformCube(Vector3 offset, Vector2[] texture,
|
||||
VisibleFaces faces, int indiciesOffset, out int[] indicies, Color color)
|
||||
VisibleFaces faces, int indiciesOffset, out int[] indicies, Color color, int light = 15)
|
||||
{
|
||||
faces = VisibleFaces.All; // Temporary
|
||||
|
||||
@ -70,7 +70,7 @@ namespace TrueCraft.Client.Rendering
|
||||
}
|
||||
var side = (CubeFace)_side;
|
||||
var quad = CreateQuad(side, offset, texture, textureIndex % texture.Length, indiciesOffset,
|
||||
out _indicies, color);
|
||||
out _indicies, new Color(color.ToVector3() * CubeBrightness[light]));
|
||||
Array.Copy(quad, 0, verticies, sidesSoFar * 4, 4);
|
||||
Array.Copy(_indicies, 0, indicies, sidesSoFar * 6, 6);
|
||||
textureIndex += 4;
|
||||
@ -88,12 +88,30 @@ namespace TrueCraft.Client.Rendering
|
||||
var quad = new VertexPositionNormalColorTexture[4];
|
||||
var unit = CubeMesh[(int)face];
|
||||
var normal = CubeNormals[(int)face];
|
||||
var faceColor = new Color(FaceBrightness[(int)face] * color.ToVector3());
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
quad[i] = new VertexPositionNormalColorTexture(offset + unit[i], normal, color, texture[textureOffset + i]);
|
||||
quad[i] = new VertexPositionNormalColorTexture(offset + unit[i], normal, faceColor, texture[textureOffset + i]);
|
||||
}
|
||||
return quad;
|
||||
}
|
||||
|
||||
protected static readonly float[] FaceBrightness =
|
||||
new float[]
|
||||
{
|
||||
0.6f, 0.6f, // North / South
|
||||
0.8f, 0.8f, // East / West
|
||||
1.0f, 0.5f // Top / Bottom
|
||||
};
|
||||
|
||||
protected static readonly float[] CubeBrightness =
|
||||
new float[]
|
||||
{
|
||||
0.050f, 0.067f, 0.085f, 0.106f, // [ 0..3 ]
|
||||
0.129f, 0.156f, 0.186f, 0.221f, // [ 4..7 ]
|
||||
0.261f, 0.309f, 0.367f, 0.437f, // [ 8..11]
|
||||
0.525f, 0.638f, 0.789f, 1.000f // [12..15]
|
||||
};
|
||||
|
||||
protected enum CubeFace
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ namespace TrueCraft.Client.Rendering.Blocks
|
||||
// Apply biome colors to top of cube
|
||||
for (int i = (int)(CubeFace.PositiveY) * 4; i < (int)(CubeFace.PositiveY) * 4 + 4; i++)
|
||||
{
|
||||
cube[i].Color = BiomeColor; // TODO: Take this from biome
|
||||
cube[i].Color = new Color(cube[i].Color.ToVector3() * BiomeColor.ToVector3()); // TODO: Take this from biome
|
||||
}
|
||||
return cube;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\targets\Client.targets" />
|
||||
<PropertyGroup>
|
||||
@ -379,8 +379,5 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Modules\" />
|
||||
<Folder Include="Content\Audio\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
Reference in New Issue
Block a user