Vertex colour is now chosen from the true, unrounded surface height and faded between adjacent materials across a tunable band, instead of switching at one rounded integer depth. This removes the horizontal contour banding. Colour path only: density field, Marching Cubes interpolation/welding, chunk dimensions, the .dat contract and all road logic are untouched. BlockID classification is unchanged and still drives non-visual use. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using Godot;
|
|
using IslaApocalypse.Core;
|
|
|
|
namespace IslaApocalypse.Client
|
|
{
|
|
// Notice this inherits from MeshInstance3D, which is Godot's visual 3D node!
|
|
public partial class ChunkRenderer : MeshInstance3D
|
|
{
|
|
public void RenderChunk(ChunkData data)
|
|
{
|
|
// 1. Pass the BlockIDs array to the generator, plus the per-column
|
|
// surface/biome/road data it needs to fade colours smoothly.
|
|
Mesh = MarchingCubes.GenerateMesh(
|
|
data.Densities, data.BlockIDs,
|
|
data.SurfaceHeights, data.ColumnBiomes, data.ColumnIsRoad,
|
|
Constants.ISO_LEVEL, Constants.VOXEL_SCALE);
|
|
|
|
|
|
StandardMaterial3D mat = new StandardMaterial3D();
|
|
|
|
// 2. THE FIX: Tell the material to use the colors we paint on the vertices!
|
|
mat.VertexColorUseAsAlbedo = true;
|
|
mat.Roughness = 0.8f;
|
|
mat.CullMode = BaseMaterial3D.CullModeEnum.Disabled;
|
|
|
|
MaterialOverride = mat;
|
|
|
|
Position = new Vector3(
|
|
data.ChunkPosition.X * Constants.CHUNK_SIZE_X * Constants.VOXEL_SCALE,
|
|
0,
|
|
data.ChunkPosition.Y * Constants.CHUNK_SIZE_Z * Constants.VOXEL_SCALE
|
|
);
|
|
}
|
|
}
|
|
}
|