Fix multiple lighting issues
- Factor in lighting for snow and similar blocks - Set default lighting value to 15 The second one is a bit of a temporary fix - the default should be 15, but we should also be revisiting and rerendering chunks once we have the neighboring chunk for this and other reasons.
This commit is contained in:
parent
04f7a86340
commit
311e7cbc25
Binary file not shown.
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
@ -125,8 +125,8 @@ namespace TrueCraft.Client.Rendering
|
||||
protected static readonly int[] DefaultLighting =
|
||||
new int[]
|
||||
{
|
||||
0, 0, 0,
|
||||
0, 0, 0
|
||||
15, 15, 15,
|
||||
15, 15, 15
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@ -144,7 +144,6 @@ namespace TrueCraft.Client.Rendering
|
||||
/// The offset coordinates used to get the position of a block for a face.
|
||||
/// </summary>
|
||||
protected static readonly Coordinates3D[] FaceCoords =
|
||||
new Coordinates3D[]
|
||||
{
|
||||
Coordinates3D.South, Coordinates3D.North,
|
||||
Coordinates3D.East, Coordinates3D.West,
|
||||
@ -185,8 +184,7 @@ namespace TrueCraft.Client.Rendering
|
||||
if ((coords.X < 0) || (coords.X >= Chunk.Width) ||
|
||||
(coords.Z < 0) || (coords.Z >= Chunk.Depth))
|
||||
{
|
||||
// TODO: Handle chunk boundaries properly.
|
||||
return 0;
|
||||
return 15;
|
||||
}
|
||||
|
||||
return Math.Min(chunk.GetBlockLight(coords) + chunk.GetSkyLight(coords), 15);
|
||||
|
@ -27,6 +27,12 @@ namespace TrueCraft.Client.Rendering.Blocks
|
||||
public override VertexPositionNormalColorTexture[] Render(BlockDescriptor descriptor, Vector3 offset,
|
||||
VisibleFaces faces, Tuple<int, int> textureMap, int indiciesOffset, out int[] indicies)
|
||||
{
|
||||
int[] lighting = new int[6];
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var coords = (descriptor.Coordinates + FaceCoords[i]);
|
||||
lighting[i] = GetLight(descriptor.Chunk, coords);
|
||||
}
|
||||
VertexPositionNormalColorTexture[] verticies;
|
||||
Vector3 correction;
|
||||
int faceCorrection = 0;
|
||||
|
@ -199,9 +199,15 @@ namespace TrueCraft.Client.Rendering.Blocks
|
||||
|
||||
protected virtual VertexPositionNormalColorTexture[] RenderSlab(BlockDescriptor descriptor, Vector3 offset, Tuple<int, int> textureMap, int indiciesOffset, out int[] indicies)
|
||||
{
|
||||
int[] lighting = new int[6];
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var coords = (descriptor.Coordinates + FaceCoords[i]);
|
||||
lighting[i] = GetLight(descriptor.Chunk, coords);
|
||||
}
|
||||
var result = CreateUniformCube(offset,
|
||||
GetTextureMap((SlabBlock.SlabMaterial)descriptor.Metadata), VisibleFaces.All,
|
||||
indiciesOffset, out indicies, Color.White);
|
||||
indiciesOffset, out indicies, Color.White, lighting);
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var face = (CubeFace)i;
|
||||
|
@ -27,7 +27,14 @@ namespace TrueCraft.Client.Rendering.Blocks
|
||||
public override VertexPositionNormalColorTexture[] Render(BlockDescriptor descriptor, Vector3 offset,
|
||||
VisibleFaces faces, Tuple<int, int> textureMap, int indiciesOffset, out int[] indicies)
|
||||
{
|
||||
var cube = CreateUniformCube(Vector3.Zero, Texture, faces, indiciesOffset, out indicies, Color.White);
|
||||
var lighting = new int[6];
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var coords = (descriptor.Coordinates + FaceCoords[i]);
|
||||
lighting[i] = GetLight(descriptor.Chunk, coords);
|
||||
}
|
||||
var cube = CreateUniformCube(Vector3.Zero, Texture, faces, indiciesOffset, out indicies,
|
||||
Color.White, lighting);
|
||||
var heightMultiplier = new Vector3(1, ((descriptor.Metadata + 1) / 16f), 1);
|
||||
for (int i = 0; i < cube.Length; i++)
|
||||
{
|
||||
|
@ -53,9 +53,15 @@ namespace TrueCraft.Client.Rendering.Blocks
|
||||
public override VertexPositionNormalColorTexture[] Render(BlockDescriptor descriptor, Vector3 offset,
|
||||
VisibleFaces faces, Tuple<int, int> textureMap, int indiciesOffset, out int[] indicies)
|
||||
{
|
||||
int[] lighting = new int[6];
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var coords = (descriptor.Coordinates + FaceCoords[i]);
|
||||
lighting[i] = GetLight(descriptor.Chunk, coords);
|
||||
}
|
||||
var centerized = new Vector3(7f / 16f, 0, 7f / 16f);
|
||||
var cube = CreateUniformCube(Vector3.Zero, Texture, VisibleFaces.All,
|
||||
indiciesOffset, out indicies, Color.White);
|
||||
indiciesOffset, out indicies, Color.White, lighting);
|
||||
for (int i = 0; i < cube.Length; i++)
|
||||
{
|
||||
cube[i].Position.X *= 1f / 8f;
|
||||
|
Loading…
x
Reference in New Issue
Block a user